<template>
    <div class="addDialog" id='addDialog'>
        <el-form
            :model="ruleForm"
            :rules="rules"
            ref="ruleForm"
            label-width="100px"
            class="demo-ruleForm"
        >
            <el-form-item label="类型名称" prop="typeName">
                <el-input v-model="ruleForm.typeName"></el-input>
            </el-form-item>
            <el-form-item label="父类id" prop="parentId">
                <el-input v-model="ruleForm.parentId"></el-input>
            </el-form-item>
            <el-form-item label="内容" prop="content">
                <el-input v-model="ruleForm.content"></el-input>
            </el-form-item>
        </el-form>
        <div class="dialogFooter">
            <el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
        </div>
    </div>
</template>
<script>
export default {
    props:{
        editOneData:{
            type: Object,
            default: {}
        }
    },
    watch:{
        editOneData:{
            handler(val) {
                this.ruleForm=val
            },
            deep: true,
            immediate: true
        }
    },
    data() {
        return {
            fileUrlList: [],
            ruleForm: {
                typeName: '',
                parentId: '',
                content: '',
                createBy: localStorage.getItem('userId')
            },
            rules: {
                typeName: [{ required: true, message: '请输入类型名称', trigger: 'blur' }],
                parentId: [{ required: true, message: '请输入父类id', trigger: 'blur' }],
                content: [{ required: true, message: '请输入内容', trigger: 'blur' }]
            }
        };
    },
    mounted() {},
    methods: {
        submitForm(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.$emit('editComment',this.ruleForm)
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        }
     }
};
</script>
<style  lang="scss">
#addDialog{
    .el-upload--text{
        border:none;
        height:32px;
        width:80px;
    }
}
</style>
<style scoped>
.el-upload--text{
    border:none;
}
.dialogFooter {
    display: flex;
    justify-content: flex-end
}
</style>